var douban = require('../../common/script/fetch')
var config = require('../../common/script/config')
var app = getApp()
Page({
  data: {
    films: [],
		hasMore: true,
		showLoading: true,
		start: 0,
    bannerList: config.bannerList
  },
  onLoad:function(){
    var that=this
    wx.showNavigationBarLoading()
    console.log("start"+that.data.start)
    app.getCity(function () {
      wx.hideNavigationBarLoading()
      wx.setNavigationBarTitle({
        title: '正在热映 - ' + config.city
      })
      douban.fetchFilms.call(that, config.apiList.popular, that.data.start)
    })
  },
  onPullDownRefresh: function () {
    var that=this;
    that.setData({
      films:[],
      hasMore:true,
      showLoading:true,
      start:0
    })
    this.onLoad()
  },
  viewFilmDetail:function(e){
    var data=e.currentTarget.dataset;
    wx.navigateTo({
      url:"../filmDetail/filmDetail?id="+data.id
    })
  }
  
  })